<?php
namespace Modules\ShopApi\Models; 
class Picture extends BaseApiModel
{	
	/**
     * @name  关联图片
     */
    public function image_one()
    {
        return $this->hasOne('Modules\Admin\Models\Image','id','image_id');
    }
	/**
     * @name  首页轮播图 
     */
	public function baner_list($type){
		$data = $this->select('id','product_id','product_status','image_id')
				->with(['image_one'=>function($query){
					$query->select('id','url','open');
				}])
				->orderBy('sort','asc')
				->orderBy('id','desc')
				->where(['type'=>$type,'status'=>1])
				->get()
				->toArray();
		$data =	$this->image_list($data);	
		return $this->api_success(['data'=>$data]);		
	}
	/**
     * @name  轮播图详情 
     */
	public function swiper_detail($id){
		$product_content = $this->where(['id'=>$id])->value('product_content');		
		$product_content =	replacePicUrl($product_content);	
		return $this->api_success(['data'=>[
			'product_content'=>$product_content
		]]);		
	}
}
